﻿using System;
using GpgCore.Products;

namespace GpgCore.GameWorld
{
    public class PeopleNeed
    {
        public ProductType ProductType;
        public double DailyIncrement;
        public double TotalAmount;
        /// <summary>
        /// In percent of Total Amount; Amount can be less than zero
        /// </summary>
        public double Delta;

        public double TotalSatisfaction;        
        public double MinIncrement;
        public double MaxIncrement;
        /// <summary>
        /// Comparing with other needs
        /// </summary>
        public double TotalNeedPercent;
        /// <summary>
        /// Influence on the population growth
        /// </summary>
        public double SatisfactionInfluence;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="satisfaction">value of satisfaction counted on ONE citizen</param>
        public void Satisfact(double satisfaction)
        {
            TotalAmount -= satisfaction;
            TotalSatisfaction = satisfaction/DailyIncrement;
            DailyIncrement += (-1 + TotalSatisfaction)*Delta;
            DailyIncrement = Math.Min(MaxIncrement, DailyIncrement);
            DailyIncrement = Math.Max(MinIncrement, DailyIncrement);

            TotalAmount += DailyIncrement;
        }
    }
}
